﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;

namespace MoControls
{
    public class DeviceStates
    {
        #region Fields

        private readonly BlendState blendState;
        private readonly RasterizerState rasterizerState;
        private readonly DepthStencilState depthStencilState;
        private readonly SamplerState samplerState;

        #endregion

        #region Properties

        public BlendState BlendState
        {
            get
            {
                return this.blendState;
            }
        }

        public RasterizerState RasterizerState
        {
            get
            {
                return this.rasterizerState;
            }
        }

        public DepthStencilState DepthStencilState
        {
            get
            {
                return this.depthStencilState;
            }
        }

        public SamplerState SamplerState
        {
            get
            {
                return this.samplerState;
            }
        }

        #endregion

        #region .ctor

        public DeviceStates()
        {
            blendState = new BlendState();
            blendState.AlphaBlendFunction = BlendState.AlphaBlend.AlphaBlendFunction;
            blendState.AlphaDestinationBlend = BlendState.AlphaBlend.AlphaDestinationBlend;
            blendState.AlphaSourceBlend = BlendState.AlphaBlend.AlphaSourceBlend;
            blendState.BlendFactor = BlendState.AlphaBlend.BlendFactor;
            blendState.ColorBlendFunction = BlendState.AlphaBlend.ColorBlendFunction;
            blendState.ColorDestinationBlend = BlendState.AlphaBlend.ColorDestinationBlend;
            blendState.ColorSourceBlend = BlendState.AlphaBlend.ColorSourceBlend;
            blendState.ColorWriteChannels = BlendState.AlphaBlend.ColorWriteChannels;
            blendState.ColorWriteChannels1 = BlendState.AlphaBlend.ColorWriteChannels1;
            blendState.ColorWriteChannels2 = BlendState.AlphaBlend.ColorWriteChannels2;
            blendState.ColorWriteChannels3 = BlendState.AlphaBlend.ColorWriteChannels3;
            blendState.MultiSampleMask = BlendState.AlphaBlend.MultiSampleMask;

            rasterizerState = new RasterizerState();
            rasterizerState.CullMode = RasterizerState.CullNone.CullMode;
            rasterizerState.DepthBias = RasterizerState.CullNone.DepthBias;
            rasterizerState.FillMode = RasterizerState.CullNone.FillMode;
            rasterizerState.MultiSampleAntiAlias = RasterizerState.CullNone.MultiSampleAntiAlias;
            rasterizerState.ScissorTestEnable = RasterizerState.CullNone.ScissorTestEnable;
            rasterizerState.SlopeScaleDepthBias = RasterizerState.CullNone.SlopeScaleDepthBias;

            rasterizerState.ScissorTestEnable = true;

            samplerState = new SamplerState();
            samplerState.AddressU = SamplerState.AnisotropicClamp.AddressU;
            samplerState.AddressV = SamplerState.AnisotropicClamp.AddressV;
            samplerState.AddressW = SamplerState.AnisotropicClamp.AddressW;
            samplerState.Filter = SamplerState.AnisotropicClamp.Filter;
            samplerState.MaxAnisotropy = SamplerState.AnisotropicClamp.MaxAnisotropy;
            samplerState.MaxMipLevel = SamplerState.AnisotropicClamp.MaxMipLevel;
            samplerState.MipMapLevelOfDetailBias = SamplerState.AnisotropicClamp.MipMapLevelOfDetailBias;

            depthStencilState = new DepthStencilState();
            depthStencilState = DepthStencilState.None;
        }

        #endregion
    }
}
